import { Directive, ElementRef, HostBinding, Input, Renderer2 } from '@angular/core';

@Directive({
  selector: '[appCustomstyle]'
})
export class CustomStyleDirective {

  constructor(private render:Renderer2,private element:ElementRef) { }

  @HostBinding("style")
  customStyle:string="";

  @Input('appCustomstyle')
  set appCustomstyle(value:Object){

    let entries=Object.entries(value);
    for (let item of entries){
      const [key,value]=item;
      if(key && value){
        // this.render.setStyle(this.element.nativeElement,key,value);
        this.customStyle=key+":"+value+";"+this.customStyle;
      }
    }
  }

}
